<?php
include("../shared/config.php");
include("../shared/lan.php");
if(!$conn)
{
  echo "连接失败了！！";
}


if($_SERVER["REQUEST_METHOD"] == "POST")
{

    if(empty($_POST["name"]) || empty($_POST["password"]))  
    {  
         echo "<a href='../page/login.php'>".$notice1."</a>";  
	exit();
    } 	
		// username and password sent from form 

		$myusername=$_POST['name']; 
		$mypassword=$_POST['password'];

		$sql="SELECT * FROM user WHERE user_name='$myusername'";
		$result=mysqli_query($conn,$sql);
		while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
			if ($row['password']==$mypassword){
				$_SESSION['login_user']=$myusername;
				$_SESSION['type']=$row['type'];//获取登录用户的身份类型
				if($_SESSION['type']==1)
				{
					header("location:../page/boss/index.php");
				}
				elseif($_SESSION['type']==0)
				{
					header("location:../page/em/index.php");
				}
			}
			else
			{
				echo "<div class='alert alert-danger alert-dismissable'>";						
				echo "		<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>";
				echo "			× ";
				echo "		</button>";
				echo "		<h4> ";
				echo $notice2;
				echo "		</h4>";
				echo "	</div>";
			}
		}
}
?>
